//
//  XQHomeData.swift
//  XQSwiftUIDemo
//
//  Created by WXQ on 2019/11/15.
//  Copyright © 2019 WXQ. All rights reserved.
//

import SwiftUI
import Combine

/// 继承改变
class XQListViewData: ObservableObject {
    
    /// 标明为 publish 属性
    @Published var sectionDataArr = [XQListViewDataSectionModel]() {
        didSet {
            print(#function, "值改变了")
            // 发送改变, 通知视图更新
            self.objectWillChange.send()
        }
    }
    
    init(dataArr: [XQListViewDataSectionModel] = []) {
        self.sectionDataArr = dataArr
        
    }
    
}

/// 遵守 Identifiable 协议
class XQListViewDataSectionModel: ObservableObject, Identifiable {
    var id = UUID()
    var deleteDisabled = true
    var moveDisabled = true
    var name: String = ""
    var datas = [XQListViewDataCellModel]()
    
    
    init(name: String = "", datas: [XQListViewDataCellModel] = []) {
        self.name = name
        self.datas = datas
    }
    
}

/// 遵守 Identifiable 协议
class XQListViewDataCellModel: ObservableObject, Identifiable {
    var id = UUID()
    var deleteDisabled = true
    var moveDisabled = true
    var name: String = ""
    
    init(name: String = "", deleteDisabled: Bool = true, moveDisabled: Bool = true) {
        self.name = name
        self.deleteDisabled = deleteDisabled
        self.moveDisabled = moveDisabled
    }
    
}

/// 如果不遵守, 那么需要外部 List 要指定 key  字段
/// List(self.dataArr, id: \.xq_id) { item in  your code  }
//struct XQHomeViewCellModel {
//    var xq_id = UUID()
//    var name: String = ""
//}





